<form id="search" action="https://www.baidu.com/s" method="get" accept-charset="utf-8" target="_blank" _lpchecked="1" onsubmit="return buildQuery()">
      {{/** the keywords **/}}
      <input type="text" id="query" maxlength="20" placeholder="Search">
      <input type="hidden" id="wd" name="wd" value="">
      <button type="submit" class="submit icon-search"></button>
</form>

<!-- Put the code of building Baidu query string here which can be easily maintained -->
<script>
    function buildQuery(){
        var queryString= document.getElementById('query').value;
        var baseUrl = "{{ .Site.BaseURL }}";
        // Remove the leading "https://" or "http://" or "//", and the "/" at the end.
        var url = baseUrl.replace(/^(https:|http:|)\/\//, "").replace(/\/$/, "");
          
        var wdElement = document.getElementById('wd');
        wdElement.value= queryString + " site:" + url;  // Baidu query string: "<keyword> site:<domain>"
        // Return true to move to next step
        return true;
    }
</script>
